#!/bin/sh

cat >  memberof_conf.ldif<<EOF 
dn: cn=module{0},cn=config
cn: modulle{0}
objectClass: olcModuleList
objectclass: top
olcModuleload: memberof.la
olcModulePath: /usr/lib64/openldap
   	
dn: olcOverlay={0}memberof,olcDatabase={2}hdb,cn=config
objectClass: olcConfig
objectClass: olcMemberOf
objectClass: olcOverlayConfig
objectClass: top
olcOverlay: memberof
olcMemberOfDangling: ignore
olcMemberOfRefInt: TRUE
olcMemberOfGroupOC: groupOfUniqueNames
olcMemberOfMemberAD: uniqueMember
olcMemberOfMemberOfAD: memberOf
EOF


cat  > refint1.ldif <<EOF
dn: cn=module{0},cn=config
add: olcmoduleload
olcmoduleload: refint
EOF

cat  > refint2.ldif << EOF
dn: olcOverlay=refint,olcDatabase={2}hdb,cn=config
objectClass: olcConfig
objectClass: olcOverlayConfig
objectClass: olcRefintConfig
objectClass: top
olcOverlay: refint
olcRefintAttribute: memberof uniqueMember  manager owner
EOF


ldapadd -Q -Y EXTERNAL -H ldapi:/// -f  memberof_conf.ldif 
ldapmodify -Q -Y EXTERNAL -H ldapi:/// -f  refint1.ldif 
ldapadd -Q -Y EXTERNAL -H ldapi:/// -f  refint2.ldif 


ldapsearch -Q -LLL -Y EXTERNAL -H ldapi:/// -b cn=config dn   |  grep olcOverlay 

